package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@LagouController
@LagouRequestMapping("/demo")
//@Security({"tomcat", "nginx"})
public class DemoController {


    @LagouAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?name=lisi
     *
     * @param request
     * @param response
     * @param name
     * @return
     */
    @LagouRequestMapping("/query")
    @Security({"tomcat","rabbitmq"})
    public String query(HttpServletRequest request, HttpServletResponse response, String name) throws IOException {
        System.out.println("访问query接口。。。。。。");
        response.getWriter().write(demoService.get(name));
        return demoService.get(name);
    }


    @LagouRequestMapping("/handler")
    @Security({"nginx","kafka"})
    public String handler(HttpServletRequest request, HttpServletResponse response, String id, String age) {
        System.out.println("访问handle接口。。。。。。参数为：id:" + id + ",age:" + age);
        return demoService.get(id);
    }
}
